package td0.Figures;


public final class Sphere extends Shape3D{
	
	private double radius;
	private Point center;
	
	public Sphere(String name, double radius, Point center) {
		super(name);
		this.radius = radius;
		this.center = center;
	}
	
	@Override
	public String toString() {
		return "Sphere " + this.getName() + " [radius=" + radius + ", center=" + center + "] volume : " + volume() + " surface : " + surface();
	}

	@Override
	public double volume() {
		return (4* Math.PI * getRadius() * getRadius() * getRadius())/3;
	}

	@Override
	public void translate(int dx, int dy) {
		getCenter().setX(dx);
		getCenter().setY(dy);
	}

	@Override
	public double surface() {
		return (4* Math.PI * getRadius() * getRadius());
	}

	public void setRadius(double radius) {
		this.radius = radius;
	}

	public double getRadius() {
		return radius;
	}

	public void setCenter(Point center) {
		this.center = center;
	}

	public Point getCenter() {
		return center;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((center == null) ? 0 : center.hashCode());
		long temp;
		temp = Double.doubleToLongBits(radius);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		Sphere other = (Sphere) obj;
		if (center == null) {
			if (other.center != null)
				return false;
		} else if (!center.equals(other.center))
			return false;
		if (Double.doubleToLongBits(radius) != Double
				.doubleToLongBits(other.radius))
			return false;
		return true;
	}

}
